<?php
declare (strict_types = 1);

namespace app\api\controller;

use think\exception\ValidateException;
use app\api\service\ApiResponse;
use app\api\traits\Curd;

class Users extends ApiController
{
    protected $modelName = 'Users';
    protected $validate = 'User';   //线索表验证器
   
    use Curd;

    public function search()
    {
        $name = $this->request->param('name');
        $validate = new \think\Validate;
        $validate->rule('name', 'require');
        if (!$validate->check(['name'=>$name])) {
            throw new ValidateException($validate->getError());
        }
        $data = $this->model->where('username','like',"%{$name}%")->select();
        return ApiResponse::success($data);
    }

    

   
}
